package com.learn.mapper;

import com.learn.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/02/24
 * @description
 */
public interface UserMapper {
    List<User> selectAllPage(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);

    List<User> selectAll();

    @Select("select * from t_user where id = #{id}")
    // 设置ResultMap属性映射, 这里id也是在Result里面设置
    @Results(value = {
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "password", column = "password"),
            @Result(property = "createTime", column = "create_time")
    })
    User selectOneAnno(Integer id);

    @Update("update t_user set name = #{name}, password = #{password}, create_time = #{createTime} where id = #{id}")
    int updateAnno(User user);

    @Insert("insert into t_user values(#{id}, #{name}, #{password}, #{createTime})")
    int insertAnno(User user);

    @Delete("delete from t_user where id = #{id}")
    int deleteAnno(Integer id);
}
